<?php
require_once("../conf/db_connection.php");

$ctr = 0;
$query_trucker = "SELECT DISTINCT(trucker_name) FROM truck";
$result_trucker = mysql_query($query_trucker) or die("SELECT TRUCKS ".mysql_error());

while($row_trucker = mysql_fetch_array($result_trucker))
{
	$query_details = "SELECT trucker_code,trucker_address, trucker_email FROM truck WHERE trucker_name='".$row_trucker['trucker_name']."' LIMIT 0,1";
	$result_details = mysql_query($query_details);
	$row_details = mysql_fetch_array($result_details);
	
	$query_ins = "INSERT INTO trucker (code, name, address, email) VALUES ('".$row_details['trucker_code']."','".$row_trucker['trucker_name']."','".$row_details['trucker_address']."','".$row_details['trucker_email']."')";
	mysql_query($query_ins) or die("INSERT FAILED :".mysql_error());
	$ctr++;
}
echo $ctr." trucker records inserted!";
?>
